package flc.ast.adapter;

import android.widget.ImageView;
import android.widget.ProgressBar;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyAudioBean;
import flc.ast.bean.RecordBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class RecordAdapter extends StkProviderMultiAdapter<RecordBean> {

    public RecordAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(122));
        addItemProvider(new RecordProvider());
    }

    private class RecordProvider extends BaseItemProvider<RecordBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, RecordBean bean) {
            baseViewHolder.setText(R.id.tvRecordItemName, bean.getFileName());
            baseViewHolder.setText(R.id.tvRecordItemComp, bean.isComp()?"已完成":"未完成");
            baseViewHolder.setText(R.id.tvRecordItemPro, bean.getProgress()+"%");
            baseViewHolder.setText(R.id.tvRecordItemFormat,bean.getFormat());
            ProgressBar pb=baseViewHolder.getView(R.id.pbFormat);
            pb.setProgress(bean.getProgress());
            if (bean.getImg()==0){
                Glide.with(getContext()).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivRecordItemImg));
            }else {
                baseViewHolder.setImageResource(R.id.ivRecordItemImg,R.drawable.yinpin1);
            }
            if (bean.isVideo()){
                baseViewHolder.setVisible(R.id.ivRecordItemPlay,true);
            }else{
                baseViewHolder.setVisible(R.id.ivRecordItemPlay,false);
            }
        }
    }

}
